"""
API路由定义
"""
from flask import Blueprint, jsonify, request

# 创建蓝图
api_bp = Blueprint('api', __name__, url_prefix='/api')

# 健康检查路由
@api_bp.route('/health', methods=['GET'])
def health_check():
    """健康检查端点"""
    return jsonify({"status": "ok", "message": "Backend service is running"})

# 版本信息路由
@api_bp.route('/version', methods=['GET'])
def version():
    """获取API版本信息"""
    from lemon_backend import __version__
    return jsonify({"version": __version__})

# 示例路由
@api_bp.route('/hello', methods=['GET'])
def hello():
    """示例问候端点"""
    return jsonify({"message": "Hello from the backend API!"})

# Echo路由
@api_bp.route('/echo', methods=['POST'])
def echo():
    """回显POST数据"""
    data = request.get_json()
    return jsonify({"echo": data})
